#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    ui->maleButton->setChecked(true);   //设置默认选项

    //将按钮进行分组，只在组内进行“排他”
    QButtonGroup* group1 = new QButtonGroup(this);
    QButtonGroup* group2 = new QButtonGroup(this);
    QButtonGroup* group3 = new QButtonGroup(this);

    group1->addButton(ui->maleButton);
    group1->addButton(ui->femaleButton);

    group2->addButton(ui->radioButton);
    group2->addButton(ui->radioButton_2);
    group2->addButton(ui->radioButton_3);

    group3->addButton(ui->radioButton_4);
    group3->addButton(ui->radioButton_5);
    group3->addButton(ui->radioButton_6);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_maleButton_clicked()
{
    ui->label->setText(QString("你的性别是：")+ui->maleButton->text());
}

void Widget::on_femaleButton_clicked()
{
    ui->label->setText(QString("你的性别是：")+ui->femaleButton->text());
}

void Widget::on_radioButton_7_toggled(bool checked)
{
    qDebug() << "State changed!" << endl;
}

void Widget::on_submitButton_clicked()
{
    QString res;
    if(ui->checkBox->isChecked())   res += ui->checkBox->text() + " ";
    if(ui->checkBox_2->isChecked())   res += ui->checkBox_2->text() + " ";
    if(ui->checkBox_3->isChecked())   res += ui->checkBox_3->text()+ " ";

    ui->schedule->setText("今天要做的事：" + res);

    qDebug() << ui->schedule->text();
}
